#include <xp/bas/system.h>
#include <xp/bas/stdio.h>

int xp_main ()
{
	xp_meminfo_t mem;
	if (xp_getmeminfo(&mem) == -1) {
		xp_printf (XP_TEXT("cannot get meminfo\n"));
		return -1;
	}

	xp_printf (XP_TEXT("mem: %llu %llu %llu\n"), 
		(unsigned long long)mem.totalram,
		(unsigned long long)mem.availram,
		(unsigned long long)mem.freeram);
	xp_printf (XP_TEXT("swap: %llu %llu %llu\n"),
		(unsigned long long)mem.totalswap,
		(unsigned long long)mem.availswap,
		(unsigned long long)mem.freeswap);

	xp_printf (XP_TEXT("mem(KB): %llu %llu %llu\n"), 
		(unsigned long long)mem.totalram / 1024,
		(unsigned long long)mem.availram / 1024,
		(unsigned long long)mem.freeram / 1024);
	xp_printf (XP_TEXT("swap(KB): %llu %llu %llu\n"),
		(unsigned long long)mem.totalswap / 1024,
		(unsigned long long)mem.availswap / 1024,
		(unsigned long long)mem.freeswap / 1024);

	xp_printf (XP_TEXT("mem(MB): %llu %llu %llu\n"), 
		(unsigned long long)mem.totalram / 1024 / 1024,
		(unsigned long long)mem.availram / 1024 / 1024,
		(unsigned long long)mem.freeram / 1024 / 1024);
	xp_printf (XP_TEXT("swap(MB): %llu %llu %llu\n"),
		(unsigned long long)mem.totalswap / 1024 / 1024,
		(unsigned long long)mem.availswap / 1024 / 1024,
		(unsigned long long)mem.freeswap / 1024 / 1024);
	
	return 0;
}

